﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Setup
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<% using (Html.BeginForm("Submit", "Home", FormMethod.Post)) { %>
<div id="accordion">
    <h3><a href="#">Requester Information</a></h3>
    <div>
        <div class="editor-label">
        <label for="txtRequester">Requester Email</label>
        </div>
        <div class="editor-label">
        <input type="text" name="requester" id="txtRequester" /> REQUIRED
        </div>
        <div class="editor-label">
        <label for="sbxLocation">Office Location</label>
        </div>
     
<div class="editor-label">
          <select name="location" size="1" id="sbxLocation">
            <option value="Roanoke Admin">Roanoke Admin</option>
            <option value="Richmond">Richmond</option>
            <option value="Hampton">Hampton</option>
            <option value="Winchester">Winchester</option>
            <option value="Roanoke MEC">Roanoke MEC</option>
            <option value="Harrisonburg MEC">Harrisonburg MEC</option>
            <option value="Wytheville MEC">Wytheville MEC</option>
            <option value="Wise MEC">Wise MEC</option>
            <option value="Starkey Autism">Starkey Autism</option>
          </select>
     </div>  
     <div class="editor-label">
        <label for="txtRequestDate">Date</label>
        </div>
        <div class="editor-label">
        <input type="text" name="requestDate" id="txtRequestDate" value="<%= System.DateTime.Now.ToString() %>" disabled="disabled"/>
        </div>
    </div>
    <h3><a href="#">Reason for Request</a></h3>
    <div>
        <input type="radio" class="rdbReason" name="reason" id="rdbEmployee" value="Employee" />
        <label for="rdbEmployee">New Hire/Employee</label><br />
        <input type="radio" class="rdbReason" name="reason" id="rdbContractor" value="Contractor" />
        <label for="rdbContractor">New Hire/Contractor</label><br />

        <input type="radio" class="rdbReason" name="reason" id="rdbChange" value="Change" />
        <label for="rdbChange">Upgrade to Current IT-setup</label><br />    
        <input type="radio" class="rdbReason" name="reason" id="rdbOther" value="Other" />
        <label for="txtOther">Other</label>        
        <input type="text" name="other" id="txtOther" /> <br />   
    </div>
    <h3><a href="#">Equipment Requested</a></h3>
    <div id="divNewEquip">
        Estimated Delivery Date: <input type="text" id="txtEffectiveDate" readonly="readonly" value="<%=System.DateTime.Now.ToShortDateString() %>"/><br />
        <select id="sbxEquipment" class="newEquipment" name="equipment_1">
        </select>
    </div>
</div>
<div id="divNewHire">
    <fieldset>
        <legend>IT User Information</legend>
            <label for="txtNewHireStart">Start Date</label>        
            <input type="text" name="startDate" id="txtNewHireStart" /> <br /> 
        <div class="editor-label">
            <label for="txtFullName">IT User's Full Name:</label>
        </div>
        <div class="editor-field">
            <input type="text" name="username" id="txtFullName" />
        </div>
        <div class="editor-label">
            <label for="txtDisplayName">DisplayName (For Distribution Lists &amp; Email):</label>
        </div>
        <div class="editor-field">
            <input type="text" name="display" id="txtDisplayName" />
        </div>
   
    <table width="650" border="0" cellspacing="0" cellpadding="2">

      <tr>
        <td colspan="2"><div align="left"><strong>Title</strong></div></td>
        <td colspan="2"><div align="left">
          <input type="text" name="title" id="txtTitle" />
        </div></td>
      </tr>
    <tr>
        <td colspan="2">
           <strong>User to model Security From</strong>
        </td>
        <td>
            <input type="text" name="security_model" id="txtSecurityModel" />
        </td>
    </tr>
      <tr>
        <td colspan="2"><div align="left"><strong>Applications Requested</strong> (Systems, Software, etc.)</div></td>
        <td colspan="2"><div align="left">
          <input type="text" name="applications" id="txtApplications" />
        </div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="left"><strong>Does user need VPN remote access</strong></div></td>
        <td><div align="left">
            <input type="radio" name="remote_access" id="rdbRemoteYes" value="Yes" />
        Yes</div></td>
        <td><div align="left">
          <input type="radio" name="remote_access" id="rdbRemoteNo" value="No" />
        No</div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="left"><strong>Printer Access</strong> (List the printers the IT User will need access to)</div></td>
        <td colspan="2"><div align="left">
          <input type="text" name="printers" id="txtPrinters" />
        </div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="left"><strong>Additional Information</strong> (Please include any relevant comments or instruction)</div></td>
        <td colspan="2"><div align="left">
          <textarea name="additional_info" id="txtAdditionalInfo" cols="45" rows="5"></textarea>
        </div></td>
      </tr>
      </table>
       </fieldset>
  </div>
        <p>
            <input type="submit" name="Submit" id="Submit" value="Submit" />
        </p>

<% } %>
    <script type="text/javascript">
        function populate(sSelector) {
            var aEquipment = [];
            $.ajax({
                'url': '/Home/GetEquipment',
                'success': function(aData) {
                    aEquipment = aData;
                    $(sSelector).empty();
                    $(sSelector).append($('<option />').attr('value', '').html('--Select--'));
                    for (sItem in aEquipment) {
                        $(sSelector).append($('<option />').attr('value', sItem).html(sItem));
                    }
                }
            });
        }
        $(document).ready(function() {
            // equipment
            populate('#sbxEquipment');

            //$('#accordion').accordion();
            $('#divNewHire').hide();
            $('#txtOther').hide();
            $('#txtNewHireStart').datepicker();
            $(".rdbReason").change(function() {
                $('#txtOther').hide();
                $('#divNewHire').hide();
                $('#txtOther').val('');
                switch ($(this).attr('id')) {
                    case 'rdbOther':
                        $('#txtOther').show();
                        break;
                    case 'rdbEmployee':
                    case 'rdbContractor':
                        $('#divNewHire').show();


                        /*({
                        modal: true,
                        width: 800,
                        buttons: {
                        Ok: function() {
                        (this).dialog('close');
                        }
                        }
                        });*/
                        break;
                }
            });
            $('.newEquipment').live('change', function() {
                var sEquipment = $(this).find(':selected').val();
                if (sEquipment != '') {
                    var sEffectiveDate = $('#txtEffectiveDate').val();
                    $.ajax({
                        'url': '/Home/GetEffectiveDate',
                        'data': { sEffectiveDate: sEffectiveDate, sEquipment: sEquipment },
                        'success': function(aData) {
                            $('#txtEffectiveDate').val(aData.sEffectiveDate);

                            var iCount = $('.newEquipment').length;
                            var sNewId = 'sbxEquipment_' + (iCount + 1);
                            var oSelect = $('<select />').attr('id', sNewId).addClass('newEquipment').attr('name', 'equipment_' + (iCount + 1));
                            $('#divNewEquip').append('<br />').append(oSelect);
                            populate('#' + sNewId);
                        }
                    });
                }
            });

        });
	</script>
</asp:Content>
